import sqlite3 as sql

conn = sql.connect('sample.db')
curs = conn.cursor()

# Create Item table
curs.execute('''create table item
  (id integer primary key, itemno text unique,
        scancode text, descr text, price real)''')
        
curs.execute("insert into item values\
            (NULL,0001,32187645,'Milk',2.50)")
curs.execute("insert into item values\
            (NULL,0002,45321876,'Beer',4.50)")
curs.execute("insert into item values\
            (NULL,0003,18764532,'Bread',1.50)")
conn.commit()

curs.execute("select * from item")
for row in curs:
    print row

curs.execute('''create table itemvendor
  (id integer primary key, itemno text, vendor text)''')
curs.execute("insert into itemvendor values\
            (NULL,0001,2345)")
curs.execute("insert into itemvendor values\
            (NULL,0002,6789)")
curs.execute("insert into itemvendor values\
            (NULL,0001,0543)")
conn.commit()

curs.execute("select * from item, itemvendor WHERE item.itemno = itemvendor.itemno")
for row in curs:
    print row
    
